getParameter():-It is used to read the parameter value for the given parameter.
getParameterNames():-It is used to get the http requese parameter.
getParameterValues():-It is used to read the http header values that is html values.
Write a program to read the form data
WAP on read the data from form.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Sample extends HttpServlet
{
public void init(ServletConfig conf)throws ServletException
{
super.init(conf);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
Enumeration em=req.getParameterNames();
String s=””;
pw.println("<html> ");
pw.println("<head></head> ");
pw.println("<body bgcolor=green> ");
while(em.hasMoreElements())
{
S=(String)em.nextElement();
Pw.println(“<br>”);
}
pw.println("</body> ");
pw.println("</html> ");
pw.close();
}
}
<html>
<head></head>
<form name=f1 action=”http://localhosyt:8080/doPost” method=post>
Name:<input type=text name=”na”><br>
Area:<input type=text name=”ar”><br>
City:<input type=text name=”ci”><br>
Pincode:<input type=text name=”pin”><br>
<input type=submit>
</form>
</html>